import {esri} from "../../api/esriAPI";

export class Measurement {
  constructor(viewManage) {
    this._viewManage = viewManage;
  }

  add(position = "bottom-left") {
    let view = this._viewManage.getMapView();
    if (!view) {
      return;
    }
    var measurementWidget = new esri.AreaMeasurement2D({
      view: view,
      unit: "square-us-feet"
    });
    view.ui.add(measurementWidget, {position});
    this._measurementWidget = measurementWidget;
  }

  /**
   * 移除比例尺
   */
  remove() {
    let view = this._viewManage.getMapView();
    if (!view) {
      return;
    }
    view.ui.remove(this._measurementWidget);
  }
}

